package com.ftw.commons.widgets

import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.ftw.commons.R
import kotlinx.android.synthetic.main.layout_menu_item.view.*

/**
 * 描    述：菜单项itemView
 * 作    者：wenjun
 * 时    间：2019/4/23  11:00 AM
 */
class MenuItemView(var mContext: Context, attrs: AttributeSet) : RelativeLayout(mContext, attrs) {

    init {
        LayoutInflater.from(mContext).inflate(R.layout.layout_menu_item, this, true)
    }


    fun bindData(resImage: Int, resString: Int, numString: String?) {
        menu_start_iv.setImageResource(resImage)
        menu_start_tv.setText(resString)
        menu_end_tv.text = numString
    }

    fun bindData(resString: Int, numString: String?) {
        menu_start_iv.visibility = View.GONE
        menu_start_tv.setText(resString)
        menu_end_tv.text = numString
    }

    fun bindData(resImage: Int, resString: Int) {
        menu_start_iv.setImageResource(resImage)
        menu_start_tv.setText(resString)
    }

    fun bindData(resString: Int) {
        menu_start_iv.visibility = View.GONE
        menu_start_tv.setText(resString)
    }

    fun bindData(resString: String) {
        menu_start_iv.visibility = View.GONE
        menu_start_tv.text = resString
    }

    fun getMenuEndIv(): ImageView {
        return menu_end_iv
    }

    fun getMenuStartTv(): TextView {
        return menu_start_tv
    }


    fun setMenuEndTv(content: String) {
        menu_end_tv.text = content
    }


    fun setShowIntoChat() {
        tv_into_chat.visibility = View.VISIBLE
    }

    fun getIntoChat(): TextView = tv_into_chat

    fun hideEndArrow() {
        menu_end_tv.setCompoundDrawablesRelative(null, null, null, null)
    }


    fun hideEndLine() {
        end_line.visibility = View.GONE
    }
}
